import { baseUrl } from './config.js';

export function channelsList(){
	return uni.request({
		url : `${baseUrl}/Chanel`,
		method : 'GET'
	})
}

export function addChannel(newChannel){
	uni.request({
		url: `${baseUrl}/Chanel`,
		method: 'POST',
		data: {
			id:'',
			title:newChannel
		},
		success: res => {console.log("success"+res)},
		fail: () => {},
		complete: () => {}
	});
}

export function getUserList(){
	var access_token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJuYmYiOjE2NTI4NTk1MDMsImV4cCI6MTY1MzQ2NDMwMywiaWF0IjoxNjUyODU5NTAzfQ.Lpa4ALB0MHrpTOaR1I9IRTmA6jJKm5c-R44NuifmBmA'
	return uni.request({
		url: "http://192.168.1.37:7161/Users",
		method: 'GET',
		header:{
			// "Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJuYmYiOjE2NTI4NTk1MDMsImV4cCI6MTY1MzQ2NDMwMywiaWF0IjoxNjUyODU5NTAzfQ.Lpa4ALB0MHrpTOaR1I9IRTmA6jJKm5c-R44NuifmBmA"
			"Authorization":`Bearer ${access_token}`
		},
		// data: {},
		// success: res => {return res}
		// fail: () => {},
		// complete: () => {}
	}).then(res=>{return res[1].data});
}

export function userlogin(uid,pwd){
	var user={"username": uid,"password": pwd}
	return uni.request({
		url: 'http://192.168.1.37:7161/Users',
		method: 'POST',
		header: {
				'Content-Type': 'application/json'
			},
		data: user,
	}).then(res=>{return res[1].data});
}